<script setup>
import { articleGetArticleDetailService } from '@/api/article'
import {ref} from 'vue'
import { formatDate } from '@/utils/format-date'
import { baseURL } from '@/utils/request'
import { htmlToText } from '@/utils/htmlToText'
const drawer = ref(false)
const articleDetail = ref()
const open = async (id)=>{
  const res = await articleGetArticleDetailService(id)
  console.log(res.data.data)
  articleDetail.value = res.data.data
  drawer.value = true
}

defineExpose({
  open
})
</script>
<template>
  <el-drawer
  title="文章预览"
  v-model="drawer"
  size="50%"
  >
    <h3>{{ articleDetail.title }}</h3>
    <span>作者: {{articleDetail.nickname }}</span><br>
    <span>发布时间: {{ formatDate(articleDetail.pub_date) }}</span><br>
    <span>文章分类: {{ articleDetail.cate_name }}</span>
    <br>
    <br>
    <img :src='baseURL + articleDetail.cover_img' alt="">
    <br>
    <p>{{ htmlToText(articleDetail.content) }}</p>
  </el-drawer>
</template>
